﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[Serializable]
public class GenData : Data
{
    public GenData() { }
    public GenData(MonoBehaviour mono) : base(mono)
    {
        UseDefaultCurves();
    }
    public void UseDefaultCurves()
    {
        curveBoneLength = Curve2.T0V1_T1V1;
        curveBoneLength.time1D = true;

        curveWidth = Curve2.T0V1_T05V1_T1V0;
        //curveWidth.time1D = true;
        curveThickness = Curve2.T0V1_T05V1_T1V0;
        //curveThickness.time1D = true;

        curveCrsSecFront = Curve2.T0V1_T05V1_T1V0;
        curveCrsSecBack = Curve2.T0V0_T1V0;
    }

    [Header("整体长度")] public float length; // 整体长度，可根据（下一项）顶点数生成
    [Header("顶点数量")] public int vertsInY = 30; // 长度上的顶点数量，或者说有多少层顶点
    public int vertsInX; // 横向（每层）有多少顶点，【readOnly】，由下面两条曲线生成

    public int sampleBetweenKeys = 4; // 曲线每两个key之间采样为顶点的数量
    public Curve2 curveCrsSecFront; // 横截面 前半形状的曲线
    public Curve2 curveCrsSecBack; // 后半

    [Header("骨骼数量")] public int bonesCount = 10; // 骨骼数量
    [Header("整体宽度")] public float width; // 整体宽度
    [Header("整体厚度")] public float thickness; // 整体厚度

    public Curve2 curveBoneLength; // 骨骼放置的间隔（也就是每段骨骼的长度）
    public Curve2 curveWidth;
    public Curve2 curveThickness;
    public GenData Clone()
    {
        var n = (GenData)MemberwiseClone();
        n.curveCrsSecFront = curveCrsSecFront.Clone();
        n.curveCrsSecBack = curveCrsSecBack.Clone();
        n.curveBoneLength = curveBoneLength.Clone();
        n.curveWidth = curveWidth.Clone();
        n.curveThickness = curveThickness.Clone();
        return n;
    }
}
